using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Turquoise.EntityGenerator.Models.Mapping
{
    public class UserGroupRoleLineMap : EntityTypeConfiguration<UserGroupRoleLine>
    {
        public UserGroupRoleLineMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("UserGroupRoleLine");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.UserGroupId).HasColumnName("UserGroupId");
            this.Property(t => t.RoleId).HasColumnName("RoleId");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
            this.Property(t => t.UpdatedBy).HasColumnName("UpdatedBy");

            // Relationships
            this.HasRequired(t => t.Role)
                .WithMany(t => t.UserGroupRoleLines)
                .HasForeignKey(d => d.RoleId);
            this.HasRequired(t => t.User)
                .WithMany(t => t.UserGroupRoleLines)
                .HasForeignKey(d => d.CreatedBy);
            this.HasRequired(t => t.User1)
                .WithMany(t => t.UserGroupRoleLines1)
                .HasForeignKey(d => d.UpdatedBy);
            this.HasRequired(t => t.UserGroup)
                .WithMany(t => t.UserGroupRoleLines)
                .HasForeignKey(d => d.UserGroupId);

        }
    }
}
